

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>nrgpy.read.txt_utils &mdash; nrgpy 0.10.19 documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html" class="icon icon-home"> nrgpy
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">nrgpy</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../../index.html">Module code</a> &raquo;</li>
        
      <li>nrgpy.read.txt_utils</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for nrgpy.read.txt_utils</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">codecs</span>
<span class="kn">import</span> <span class="nn">datetime</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>
<span class="kn">from</span> <span class="nn">glob</span> <span class="kn">import</span> <span class="n">glob</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="kn">from</span> <span class="nn">nrgpy.read.channel_info_arrays</span> <span class="kn">import</span> <span class="n">return_array</span>
<span class="kn">from</span> <span class="nn">nrgpy.utils.utilities</span> <span class="kn">import</span> <span class="n">check_platform</span><span class="p">,</span> <span class="n">windows_folder_path</span><span class="p">,</span> <span class="n">linux_folder_path</span><span class="p">,</span> <span class="n">draw_progress_bar</span><span class="p">,</span> <span class="n">renamer</span>


<div class="viewcode-block" id="read_text_data"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.txt_utils.read_text_data">[docs]</a><span class="k">class</span> <span class="nc">read_text_data</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;class for handling known csv-style text data files with header information</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    filename : str, optional</span>
<span class="sd">        perform a single file read (takes precedence over txt_dir)</span>
<span class="sd">    data_type : str</span>
<span class="sd">        specify instrument that the data file came from</span>
<span class="sd">    sep : str</span>
<span class="sd">        &#39;\t&#39;; csv separator</span>

<span class="sd">    txt_dir : str</span>
<span class="sd">        folder path of text files to read and concatenate</span>
<span class="sd">    file_filter : str, optional</span>
<span class="sd">        use when using txt_dir to filter on subset of files</span>
<span class="sd">    file_ext : str, optional</span>
<span class="sd">        secondary file filter</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">data_type</span><span class="o">=</span><span class="s1">&#39;sp3&#39;</span><span class="p">,</span> <span class="n">txt_dir</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">file_filter</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
                 <span class="n">filter2</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">file_ext</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s1">&#39;</span><span class="se">\t</span><span class="s1">&#39;</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">data_type</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;data_type parameter required.&quot;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">SymphoniePRO   : use &#39;data_type=&#39;symphoniepro&#39;&quot;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">SymphoniePLUS3 : use &#39;data_type=&#39;symphonieplus3&#39;&quot;</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">False</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">data_type</span> <span class="o">=</span> <span class="n">data_type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span> <span class="o">=</span> <span class="n">txt_dir</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span> <span class="o">=</span> <span class="n">file_filter</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filter2</span> <span class="o">=</span> <span class="n">filter2</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">file_ext</span> <span class="o">=</span> <span class="n">file_ext</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sep</span> <span class="o">=</span> <span class="n">sep</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ch_info_array</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">header_sections</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">skip_rows</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_type</span> <span class="o">=</span> <span class="n">return_array</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data_type</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">=</span> <span class="n">filename</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">get_head</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">get_site_info</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">arrange_ch_info</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">get_data</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_number</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)[:</span><span class="mi">4</span><span class="p">]</span>

        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span><span class="p">:</span>
            <span class="c1"># self.concat()</span>
            <span class="k">pass</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;set filename or txt_dir parameters to proceed.&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s1">&#39;&lt;class </span><span class="si">{}</span><span class="s1">: </span><span class="si">{}</span><span class="s1"> &gt;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>

<div class="viewcode-block" id="read_text_data.arrange_ch_info"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.txt_utils.read_text_data.arrange_ch_info">[docs]</a>    <span class="k">def</span> <span class="nf">arrange_ch_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;generates list and dataframe of channel information&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">()</span>
        <span class="n">ch_data</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">ch_list</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">ch_details</span> <span class="o">=</span> <span class="mi">0</span>

        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">iterrows</span><span class="p">():</span>

            <span class="k">if</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info_array</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="n">ch_details</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>  <span class="c1"># start channel data read</span>
                <span class="n">ch_details</span> <span class="o">=</span> <span class="mi">1</span>
                <span class="n">ch_data</span><span class="p">[</span><span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>

            <span class="k">elif</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info_array</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="n">ch_details</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>  <span class="c1"># close channel, start new data read</span>
                <span class="n">ch_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ch_data</span><span class="p">)</span>
                <span class="n">ch_data</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="n">ch_data</span><span class="p">[</span><span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>

            <span class="k">elif</span> <span class="nb">str</span><span class="p">(</span><span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span> <span class="ow">in</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info_array</span><span class="p">):</span>
                <span class="n">ch_data</span><span class="p">[</span><span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>

        <span class="n">ch_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ch_data</span><span class="p">)</span>  <span class="c1"># last channel&#39;s data</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">ch_list</span> <span class="o">=</span> <span class="n">ch_list</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ch_list</span><span class="p">)</span></div>

<div class="viewcode-block" id="read_text_data.concat"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.txt_utils.read_text_data.concat">[docs]</a>    <span class="k">def</span> <span class="nf">concat</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output_txt</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">out_file</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">file_filter</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">filter2</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">progress_bar</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;combine exported rwd files (in txt format)</span>

<span class="sd">        parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        output_txt : bool</span>
<span class="sd">            set to True to save a concatenated text file</span>
<span class="sd">        out_file : str</span>
<span class="sd">            filepath, absolute or relative</span>
<span class="sd">        file_filter : str</span>
<span class="sd">        filter2 : str</span>
<span class="sd">        progress_bar : bool</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span> <span class="o">=</span> <span class="n">file_filter</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">filter2</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">filter2</span> <span class="o">=</span> <span class="n">filter2</span>

        <span class="k">if</span> <span class="n">check_platform</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;win32&#39;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span> <span class="o">=</span> <span class="n">windows_folder_path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span> <span class="o">=</span> <span class="n">linux_folder_path</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span><span class="p">)</span>

        <span class="n">first_file</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="n">files</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">glob</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span> <span class="o">+</span> <span class="s1">&#39;*.txt&#39;</span><span class="p">))</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">file_count</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">files</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">file_count</span><span class="p">))</span> <span class="o">+</span> <span class="mi">1</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">counter</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">start_time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span>

        <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>

            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span> <span class="ow">in</span> <span class="n">f</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">filter2</span> <span class="ow">in</span> <span class="n">f</span><span class="p">:</span>

                <span class="k">if</span> <span class="n">progress_bar</span><span class="p">:</span>
                    <span class="n">draw_progress_bar</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">counter</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">file_count</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">start_time</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Adding  </span><span class="si">{0}</span><span class="s2">/</span><span class="si">{1}</span><span class="s2">  </span><span class="si">{2}</span><span class="s2">  ...  &quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">counter</span><span class="p">)</span><span class="o">.</span><span class="n">rjust</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">file_count</span><span class="p">)</span><span class="o">.</span><span class="n">ljust</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">),</span> <span class="n">f</span><span class="p">),</span> <span class="n">end</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">flush</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

                <span class="k">if</span> <span class="n">first_file</span><span class="p">:</span>
                    <span class="n">first_file</span> <span class="o">=</span> <span class="kc">False</span>

                    <span class="k">try</span><span class="p">:</span>
                        <span class="n">base</span> <span class="o">=</span> <span class="n">read_text_data</span><span class="p">(</span>
                            <span class="n">filename</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> <span class="n">data_type</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data_type</span><span class="p">,</span>
                            <span class="n">file_filter</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span><span class="p">,</span> <span class="n">file_ext</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">file_ext</span><span class="p">,</span>
                            <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span>
                        <span class="p">)</span>
                        <span class="k">if</span> <span class="ow">not</span> <span class="n">progress_bar</span><span class="p">:</span>
                            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[OK]&quot;</span><span class="p">)</span>
                        <span class="k">pass</span>

                    <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
                        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Only standard headertypes accepted&#39;</span><span class="p">)</span>
                        <span class="k">break</span>

                <span class="k">else</span><span class="p">:</span>
                    <span class="n">file_path</span> <span class="o">=</span> <span class="n">f</span>
                    <span class="k">try</span><span class="p">:</span>
                        <span class="n">s</span> <span class="o">=</span> <span class="n">read_text_data</span><span class="p">(</span>
                            <span class="n">filename</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> <span class="n">data_type</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">data_type</span><span class="p">,</span>
                            <span class="n">file_filter</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span><span class="p">,</span> <span class="n">file_ext</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">file_ext</span><span class="p">,</span>
                            <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span>
                        <span class="p">)</span>
                        <span class="n">base</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">base</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">data</span><span class="p">,</span> <span class="n">sort</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
                        <span class="k">if</span> <span class="ow">not</span> <span class="n">progress_bar</span><span class="p">:</span>
                            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[OK]&quot;</span><span class="p">)</span>
                    <span class="k">except</span><span class="p">:</span>
                        <span class="k">if</span> <span class="ow">not</span> <span class="n">progress_bar</span><span class="p">:</span>
                            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[FAILED]&quot;</span><span class="p">)</span>
                        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;could not concat </span><span class="si">{0}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">file_path</span><span class="p">))</span>
                        <span class="k">pass</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">pass</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">counter</span> <span class="o">+=</span> <span class="mi">1</span>

        <span class="k">if</span> <span class="n">output_txt</span><span class="p">:</span>

            <span class="k">if</span> <span class="n">out_file</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                <span class="n">out_file</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">data_type</span><span class="si">}</span><span class="s2">_&quot;</span> <span class="o">+</span> <span class="n">datetime</span><span class="o">.</span><span class="n">today</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2">&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;.txt&quot;</span>
            <span class="n">base</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">out_file</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s1">&#39;,&#39;</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">out_file</span> <span class="o">=</span> <span class="n">out_file</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">ch_info</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ch_list</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">ch_list</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">base</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">drop_duplicates</span><span class="p">(</span><span class="n">subset</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">header_sections</span><span class="p">[</span><span class="s1">&#39;data_header&#39;</span><span class="p">]],</span> <span class="n">keep</span><span class="o">=</span><span class="s1">&#39;first&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">head</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">head</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">site_info</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">filename</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_number</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">][:</span><span class="mi">4</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">format_rwd_site_data</span><span class="p">()</span>

        <span class="k">except</span> <span class="ne">UnboundLocalError</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No files match to contatenate.&quot;</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">None</span></div>

<div class="viewcode-block" id="read_text_data.get_site_info"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.txt_utils.read_text_data.get_site_info">[docs]</a>    <span class="k">def</span> <span class="nf">get_site_info</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_file</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;create dataframe of site info&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">header_len</span> <span class="o">=</span> <span class="mi">0</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">()</span>

        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;ISO-8859-1&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">txt_file</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">txt_file</span><span class="p">:</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">header_sections</span><span class="p">[</span><span class="s1">&#39;data_header&#39;</span><span class="p">]</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                    <span class="k">break</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">header_len</span> <span class="o">+=</span> <span class="mi">1</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span>
            <span class="n">_file</span><span class="p">,</span> <span class="n">skiprows</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">skip_rows</span><span class="p">,</span> <span class="n">skip_blank_lines</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
            <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">header_len</span><span class="p">,</span>
            <span class="n">header</span><span class="o">=</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;ISO-8859-1&#39;</span><span class="p">,</span>
            <span class="n">error_bad_lines</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">warn_bad_lines</span><span class="o">=</span><span class="kc">False</span>
        <span class="p">)</span>  <span class="c1"># usecols=[0,1],</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_type</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;symphonieplus3&quot;</span><span class="p">,</span> <span class="s2">&quot;symplus3&quot;</span><span class="p">,</span> <span class="s2">&quot;sp3&quot;</span><span class="p">,</span> <span class="s2">&quot;rwd&quot;</span><span class="p">,</span> <span class="s2">&quot;4941&quot;</span><span class="p">]:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">reset_index</span><span class="p">(</span><span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>  <span class="c1"># , drop=True) works, but only for spro</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">format_rwd_site_data</span><span class="p">()</span></div>
        <span class="c1"># self.site_info = self.site_info.iloc[:self.site_info.iloc[self.site_info[0]==self.header_sections[&#39;data_header&#39;]].index.tolist()[0]+1]</span>

<div class="viewcode-block" id="read_text_data.get_head"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.txt_utils.read_text_data.get_head">[docs]</a>    <span class="k">def</span> <span class="nf">get_head</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_file</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;get the first lines of the file</span>

<span class="sd">        excluding those without tabs up to the self.skip_rows line</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">head</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>

        <span class="k">with</span> <span class="n">codecs</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">_file</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="s1">&#39;ISO-8859-1&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">head_f</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">head_f</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">i</span> <span class="o">&gt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">skip_rows</span><span class="p">:</span>
                    <span class="k">break</span>
                <span class="k">if</span> <span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">head</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">))</span>
                <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span></div>

<div class="viewcode-block" id="read_text_data.get_data"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.txt_utils.read_text_data.get_data">[docs]</a>    <span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_file</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;create dataframe of tabulated data&quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_type</span> <span class="o">==</span> <span class="s2">&quot;sympro&quot;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">header_len</span> <span class="o">+=</span> <span class="mi">1</span>  <span class="c1"># this shouldn&#39;t be necessary; something with get_site_info?</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span>
            <span class="n">_file</span><span class="p">,</span> <span class="n">skiprows</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">header_len</span><span class="p">,</span>
            <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;ISO-8859-1&#39;</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span>
        <span class="p">)</span></div>

<div class="viewcode-block" id="read_text_data.format_rwd_site_data"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.txt_utils.read_text_data.format_rwd_site_data">[docs]</a>    <span class="k">def</span> <span class="nf">format_rwd_site_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;adds formatted site dataframe to reader object&quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">Site_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Site_info</span><span class="o">.</span><span class="n">T</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
            <span class="n">width</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span><span class="o">.</span><span class="n">values</span><span class="p">)</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s1">&#39;-----Sensor Information-----&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">iloc</span><span class="p">[:,</span> <span class="n">width</span><span class="p">:</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span><span class="p">)],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">errors</span><span class="o">=</span><span class="s1">&#39;ignore&#39;</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">latitude</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Latitude&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">longitude</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Longitude&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">elevation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Site Elevation&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">location</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Site Location&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_description</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Site Desc&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">logger_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">head</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">logger_sn</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">logger_type</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">head</span><span class="p">[</span><span class="mi">2</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ipack_sn</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ipack_type</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">time_zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Time offset (hrs)&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">e</span> <span class="o">=</span> <span class="n">e</span>
            <span class="kn">import</span> <span class="nn">traceback</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Warning: error processing site_info: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">()))</span></div></div>


<div class="viewcode-block" id="format_sympro_site_data"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.txt_utils.format_sympro_site_data">[docs]</a><span class="k">def</span> <span class="nf">format_sympro_site_data</span><span class="p">(</span><span class="n">reader</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;adds formatted site dataframe to reader object&quot;&quot;&quot;</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">Site_info</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">Site_info</span><span class="o">.</span><span class="n">T</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
        <span class="n">width</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span><span class="o">.</span><span class="n">values</span><span class="p">)</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s1">&#39;Sensor History&#39;</span><span class="p">)</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="n">renamer</span><span class="p">(),</span> <span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">iloc</span><span class="p">[:,</span> <span class="n">width</span><span class="p">:</span><span class="nb">len</span><span class="p">(</span><span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span><span class="p">)],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">errors</span><span class="o">=</span><span class="s1">&#39;ignore&#39;</span><span class="p">)</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">col</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;:&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span><span class="p">]</span>

        <span class="n">reader</span><span class="o">.</span><span class="n">latitude</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Latitude&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">longitude</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Longitude&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">elevation</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Elevation&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">site_number</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Site Number&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">site_description</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Site Description&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">start_date</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Start Date&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">logger_sn</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Serial Number&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">ipack_sn</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Serial Number_1&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">logger_type</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Model&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">ipack_type</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Model_1&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">time_zone</span> <span class="o">=</span> <span class="n">reader</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Time Zone&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="n">reader</span><span class="o">.</span><span class="n">e</span> <span class="o">=</span> <span class="n">e</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Warning: error processing site_info: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">e</span><span class="p">))</span></div>
</pre></div>

           </div>
           
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2020, NRG Systems, Technical Services.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>